#ifndef TCPSEVER_H
#define TCPSEVER_H

#include <QObject>
#include <QVector>
#include <QMap>
#include <QSqlDatabase>
#include <QSqlError>
#include <QSqlQuery>
#include <QSqlRecord>
#include <QTcpServer>
#include <QTcpSocket>
#include <databasemanager.h>
#include "log.h"

class ServerManager : public QObject {
    Q_OBJECT
public:
    QTcpServer* server=nullptr;
    QList<QTcpSocket*> clients;
};


class TCpsever : public QObject
{
    Q_OBJECT
public:
    explicit TCpsever(QObject *parent = nullptr);
    QString type;

    QMap<int, QVector<QVariant>> readDatabase(QSqlDatabase db);

    void setupTcpServer(int key,QVector<QVariant> Row);

signals:
        void serverDataReceived(int index, const QByteArray& data);
public slots:
        void onserverDataReceived(int index, const QByteArray& data);

private:
        QMap<int, QVector<QVariant>> serviceData;
        QMap<int,ServerManager*> servermanager;
        QMap<int ,TCpsever> value;
        Log* m_logger;
};

#endif // TCPSEVER_H
